ReplaceInPlace Generic Method

Wintellect PowerCollections

Collapse imageExpand ImageCollapseAll imageExpandAll imageDropDown imageDropDownHover imageCopy imageCopyHover image
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Replace all items in a list or array that a predicate evaluates at true with a value. The replacement is done in-place, changing the list.

Namespace: Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax

C#
public static void ReplaceInPlace<T>(
	IList<T> list,
	Predicate<T> predicate,
	T replaceWith
)
Visual Basic (Declaration)
Public Shared Sub ReplaceInPlace(Of T) ( _
	list As IList(Of T), _
	predicate As Predicate(Of T), _
	replaceWith As T _
)
Visual C++
public:
generic<typename T>
static void ReplaceInPlace (
	IList<T>^ list, 
	Predicate<T>^ predicate, 
	T replaceWith
)

Parameters

list
IList<(Of <T>)>
The list or array to process.
predicate
Predicate<(Of <T>)>
The predicate used to evaluate items with the collection. If the predicate returns true for a particular item, the item is replaces with replaceWith.
replaceWith
T
The new value to replace with.

Type Parameters

T

Remarks

Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as list.

See Also